package com.qf.leadnewswemedia.controller.v1;

import com.qf.leadnewsmodel.dtos.PageRequestDto;
import com.qf.leadnewsmodel.dtos.ResponseResult;
import com.qf.leadnewswemedia.model.dtos.NewsPageRequestDto;
import com.qf.leadnewswemedia.model.dtos.WmNewsDto;
import com.qf.leadnewswemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.UnsupportedEncodingException;

@RestController
@RequestMapping("/api/v1/news")
public class WmNewsController {

    @Autowired
    private WmNewsService wmNewsService;

    @PostMapping("/submit")
    public ResponseResult submit(@RequestBody WmNewsDto wmNewsDto) throws UnsupportedEncodingException {

        return wmNewsService.submit(wmNewsDto);
    }

    @PostMapping("/list")
    public ResponseResult list(@RequestBody NewsPageRequestDto pageRequestDto){
        return wmNewsService.pageList(pageRequestDto);
    }
}
